﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;
using System.Drawing;
using System.Web.SessionState;

namespace BloodBank
{
   

    public partial class Rception : System.Web.UI.Page
    {
        //int pnumber = 0;
       
        
        
       
        void setdonor_info(Donor x) {
            x._name =name.Text;
            x._birthdate =bdate.Text;
            x._address = address.Text;
            x._phone = tel.Text;
            x._ssn =nid.Text;
            x._email = mail.Text;
            x._gender = gender.SelectedValue;
            x._job = job.Text;
            
        }

        
        void set_donationprocess_data(DonationProcess t) {
            t._barcode = Convert.ToInt32(ba_code.Text);
            t._donation_type = don_type.SelectedValue;
            t._firsttimedonate = pr_don.SelectedValue;

            t._last_donation_date = l_donation.Text;
            t._complains = bdon.SelectedValue;
            t._healthproblems = helth_pro.SelectedValue;
            t._vacination = m_s.SelectedValue;
            t._travel = t_r.SelectedValue;
            t._tratment = d_rag.SelectedValue;
            t._medicaloperation = su_gry.SelectedValue;
            t._blood_transfusion = bloo_d_movement.SelectedValue;
            t._infection = c_patient.SelectedValue;
            t._pregnance = pre_gnant.SelectedValue;
            t._anydesiease = a_rad.SelectedValue;
            t._take_drugs = dr_gs.SelectedValue;
            t._do_sex = do_sex.SelectedValue;
            t._contenous_donation = w_need.SelectedValue;
            t._anydesiease = a_rad.SelectedValue;
            t._ssn = nid.Text;

        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if ((Request.UserAgent.IndexOf("AppleWebKit") > 0) || (Request.UserAgent.IndexOf("Unknown") > 0) || (Request.UserAgent.IndexOf("Chrome") > 0))
                {
                    Request.Browser.Adapters.Clear();
                }
            }
        } 

        
       
        protected void Page_Load(object sender, EventArgs e)
        {
            //sql connection

           
           
            if (!this.IsPostBack)
            {
            
              
            }
           

        }

        

        protected void add_Click(object sender, EventArgs e)
        {
            Receptionist re1 = new Receptionist();
            Donor do1 = new Donor();
            DonationProcess d1 = new DonationProcess();

       
        setdonor_info(do1);
        set_donationprocess_data(d1);
        if (re1.add(do1,d1) == true)
        {
            //Response.Redirect(Request.Url.PathAndQuery, true);
            //session groups to check final state
            Session["process_barcode"] = ba_code.Text;
            Session["diseases"] = a_rad.SelectedValue;
            Session["cohol"] = dr_gs.SelectedValue;
            Session["sex_relation"] = do_sex.SelectedValue;
            Session["gender"] = gender.SelectedValue;
            Session["name"] = name.Text;
            //-------------
            
            //----------
            
            Response.Redirect("~/confirm.aspx");
            
        }

        else {
            error.Visible = true;

        }
       
        

        }

       

        protected void do_search_Click(object sender, EventArgs e)
        {

        }

       
        
                
                
                  
                

           
        

        


      

       
        }

        
        
        
    }
